package com.sl.au.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.sl.au.entity.Account;
import com.sl.au.entity.EventRegister;
import com.sl.au.entity.EventReport;
import com.sl.au.entity.Module;
import com.sl.au.entity.Option;
import com.sl.au.entity.User;
import com.sl.au.service.EventRegisterService;
import com.sl.au.service.EventReportService;
import com.sl.au.service.EventToEvaluateUserService;
import com.sl.au.service.ModuleService;
import com.sl.au.service.OptionService;
import com.sl.au.service.UserEventTypeBindInfoService;
import com.sl.au.service.VisitorRewardService;
import com.sl.utils.ExdeUtil;

/**
 * 手机端应用中心
 * @author yangdi
 *
 */

@RestController
@RequestMapping(value = "/ui/Application") 
public class ApplicationController  extends BaseController{
	
	@Autowired
	private EventRegisterService eventRegisterService;
	@Autowired
	private EventReportService eventReportService;
	@Autowired
	private OptionService optionService;
	@Autowired
	private VisitorRewardService visitorRewardService;
	@Autowired
	private EventToEvaluateUserService eventToEvaluateUserService;
	@Autowired
	private UserEventTypeBindInfoService userEventTypeBindInfoService;
	@Autowired
	private ModuleService moduleService;
	
	@RequestMapping(method = RequestMethod.GET)
	public ModelAndView index(ModelAndView modelAndView,HttpServletRequest request) {
		String device = request.getParameter("device");
		String identify = request.getParameter("identify");
		if (StringUtils.hasText(device) && this.DEVICE.equals(device)) {
			modelAndView.setViewName("mobile/application/applicationIndex");
			modelAndView.addObject("identify", identify);
			modelAndView.addObject("account", this.getMyAccount());
		}
		return modelAndView;
	}
	
	@RequestMapping(value = "getMenu", method = RequestMethod.GET)
	public Map<String, Object> getMenu() {
		Map<String, Object> map = new HashMap<String, Object>();
		List<Module> menus = moduleService.getRepository().findModulesMenuAndParent(this.getMyAccount().getRole().getId(), "Application");
		map.put("menus", menus);
		return map;
	}
	
}
